package com.woniuxy.controller;

import com.woniuxy.entity.Type;
import com.woniuxy.entity.User;
import com.woniuxy.service.UserService;
import com.woniuxy.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/life/user")
public class UserController {
    @Autowired
    private UserService userServiceImpl;

    /*
    * 根据userId查询用户的所有信息
    * */
    @GetMapping("/findUserInfoByUserId")
    public ResponseResult<User> findUserInfoByUserId(@RequestParam("userId") Integer userId){
        User user =userServiceImpl.findUserInfoByUserId(userId);
        System.out.println("user: " + user);
        return ResponseResult.success(user);
    }

    /*
    *根据id修改用户信息
    * */
    @PutMapping("/updateUserInfo")
    public ResponseResult<Void> updateUserInfo(@RequestBody User user){
        userServiceImpl.updateByUserId(user);
        return ResponseResult.success();
    }



}
